<!DOCTYPE html>
<html lang="zh">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/header :: header(~{::title},~{::link},~{})">
    <title>开启点餐</title>
    <link rel="icon" th:href="@{/assets/img/lcxm.ico}" type="image/ico">
</head>
<body class="body">
<!--导航-->
<div th:replace="common/nav :: nav(true)"></div>

<div class="container">

    <div class="row">
        <div style="margin-top: 20px;"></div>
        <div class="row">

            <form class="form-horizontal validate" role="form" method="post" th:action="@{/start/save}"
                  onsubmit="return checkForm(this);">

                <!-- 操作信息提示的地方 -->
                <div th:if="${remind}" class="alert alert-${ remind.level  }"
                     th:classappend="'alert-' + ${remind.level}">
                    <button data-dismiss="alert" class="close" type="button">
                        <i class="glyphicon glyphicon-remove"></i>
                    </button>
                    <span th:remove="tag" th:utext="${ remind.message }"></span>
                </div>


                <div class="form-group">

                    <label for="title" class="col-sm-2 control-label">标题*</label>
                    <div class="col-sm-6 ">
                        <input type="hidden" name="id" th:value="${ entity?.id }">
                        <input type="text" class="form-control" id="title" name="title" th:value="${ entity?.title }"
                               placeholder="请输入标题">
                    </div>
                    <div class="col-sm-4  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="endTime" class="col-sm-2 control-label">结束时间*</label>
                    <div class="col-sm-6 ">
                        <input type="text" class="form-control datetime" id="endTime" name="endTime"
                               data-format="hh:ii"
                               data-date-format="hh:ii"
                               data-max-view="1"
                               data-min-view="0"
                               data-start-view="1"
                               data-start-date-target="now"
                               th:attrappend="data-initial-date=${ entity?.getEndTime()}, data-value=${ entity?.getEndTimeStr() }"
                               readonly="readonly"
                               placeholder="请输入结束时间">
                    </div>
                    <div class="col-sm-4  help-inline form-control-static"></div>
                </div>
                <hr/>

                <div class="form-group" th:each="cur:${selects}">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-6 ">
                        <div class="alert " th:classappend="${cur.isSelected()? 'alert-warning' : 'alert-danger'}">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name="code" th:value="${cur.code}"
                                           th:checked="${cur.isSelected()}">
                                    [[${cur.text}]]
                                </label>

                            </div>
                        </div>
                    </div>
                </div>

                <hr/>

                <div class="form-group clearfix">
                    <div class="text-center col-sm-9">
                        <button type="submit" class="btn btn-lg btn-primary">
                            <i class="glyphicon glyphicon-ok"></i> 提交
                        </button>
                        <button th:if="${ entity?.id }" type="button" class="btn btn-lg  btn-danger action-post"
                                th:attrappend="data-url='/start/finish/'+${ entity?.id }"
                                data-confirm="确定结束点餐吗">
                            <i class="glyphicon glyphicon-remove"></i> 结束点餐
                        </button>
                        <a type="button" class="btn btn-lg  btn-info" th:href="@{/start/}">
                            <i class="glyphicon glyphicon-repeat"></i> 返回开启列表
                        </a>
                    </div>
                </div>

            </form>


        </div>


    </div>
</div>


<!-- 引入通用js-->
<div th:replace="common/footer :: footer"></div>
<script>
    function checkForm(form) {
        debugger;
        var title = $("#title").val();
        var endTime = $("#endTime").val();
        var size = $("input[name=code]").filter(":checked").size();
        if (title && endTime && size > 0) {
            return true;
        }
        $.alert({
            theme: 'bootstrap',
            title: '温馨提示',
            content: '请填写完整'
        });
        return false;
    };
</script>
</body>
</html>